import { defineStore } from 'pinia';
import categoryApi from '@/api/category';
import type { CategoryL1ListType } from '@/api/category';
type stateData = {
  categoryL1List: CategoryL1ListType;
};
export const useCategoryStore = defineStore('category', {
  state: (): stateData => {
    return {
      categoryL1List: [],
    };
  },
  actions: {
    async getCategoryList() {
      try {
        const res = await categoryApi.reqCategoryList();
        if (res.data.code === 200) {
          this.categoryL1List = res.data.data.categoryL1List;
          return 'ok';
        }
      } catch (error) {
        return Promise.reject('fail');
      }
    },
  },
  getters:{
    
  }
});
